package controllers

import (
	"../../../deps/lessgo/pagelet"
	"../../conf"
	"../../store"
	"../models/session"
)

type Index struct {
	*pagelet.Controller
}

func (c Index) IndexAction() {

	if !session.IsLogin(c.Request) {
		c.ViewData["bootAction"] = "user/login"
		return
	}

	keeperid := store.Cmd("HGET", "sys:keeper", "id").String()
	if len(keeperid) < 8 {
		c.ViewData["bootAction"] = "setup/init"
		return
	}

	c.ViewData["bootAction"] = "index/panel"
}

func (c Index) PanelAction() {

	if !session.IsLogin(c.Request) {
		return
	}

	c.ViewData["webui_banner_title"] = "Keeper Manager"

	menus := []map[string]string{
		{"path": "#index/dash", "title": "Overview"},
		// {"path": "#host/list", "title": "Hosts"},
		{"path": "#bucket/list", "title": "Buckets"},
		// {"path": "#key/list", "title": "Access Keys"},
		//{"path": "#setup/index", "title": "Settings"},
	}
	c.ViewData["menus"] = menus

	c.ViewData["version"] = conf.VERSION
}

func (c Index) DashAction() {
	if !session.IsLogin(c.Request) {
		return
	}
}
